package org.liuchang.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.liuchang.model.Pay;
import org.liuchang.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "消息", description = "消息操作 API", position = 100, protocols = "http")
@RestController
@RequestMapping("/")
public class PayController {

    @Autowired
    private PayService payService;

    @ApiOperation(
            value = "新增",
            notes = "新增pay",
            produces="application/json",
            consumes="application/json",
            response = String.class)
    @PostMapping(value = "/pay")
    public String create(@RequestBody Pay pay) {
        int i = payService.insert(pay);
        String result;
        if (i > 0) {
            result = "success";
        } else {
            result = "fail";
        }
        return result;
    }

    @ApiOperation(
            value = "查询",
            notes = "根据id查询内容",
            produces="application/json",
            consumes="application/json",
            response = Pay.class)
    @GetMapping(value = "/pay/{id}")
    public Pay pay(@PathVariable int id) {
        return payService.selectById(id);
    }
}
